const { Sequelize, DataTypes } = require('sequelize');

// 实例化Sequelize，完成链接配置
const sequelize = new Sequelize('node', 'root', '123456', {
    host: 'localhost',
    dialect: 'mysql',
    dialectOptions: { charset: "utf8mb4" },
    define: {
        underscored: true,
        charset: 'utf8mb4',
        freezeTableName: true
    },
    pool: {
        max: 5,
        min: 0,
        idle: 10000
    }
});

(async function() {
    try {
        // 做链接校验
        await sequelize.authenticate();
        console.log('连接成功');
    } catch (error) {
        console.error('Unable to connect to the database:', error);
    }
})();
